package com.reeygu.cli.command;

import cn.hutool.core.bean.BeanUtil;
import com.reeygu.generator.file.GeneratorMainTemplate;
import com.reeygu.model.MainTemplateConfig;
import lombok.Data;
import picocli.CommandLine;

import java.util.concurrent.Callable;

/**
 * @describe: 构建代码子命令
 * @author: ReeyGu
 * @data: 2024/3/29 18:57
*/
@Data
@CommandLine.Command(name = "generator", version = "1.0", mixinStandardHelpOptions = true)
public class GeneratorCommand implements Callable<Integer> {

    // 作者名称
    @CommandLine.Option(names = { "-u", "--username" }, arity = "0..1",
            description = "username", prompt = "author:", interactive = true, echo = true)
    private String username;

    // 题目编号
    @CommandLine.Option(names = { "-n", "--no" }, arity = "0..1",
            description = "no", prompt = "title:", interactive = true, echo = true)
    private Integer no;

    // 输出风格
    @CommandLine.Option(names = { "-s", "--style" }, arity = "0..1",
            description = "outputStyle", prompt = "style:", interactive = true, echo = true)
    private Integer outputStyle;

    // 是否开启循环
    @CommandLine.Option(names = { "-w", "--while" }, arity = "0..1",
            description = "isWhile", prompt = "start while:", interactive = true, echo = true)
    private boolean isWhile;

    // 输出标题
    @CommandLine.Option(names = { "-o", "--output" }, arity = "0..1",
            description = "answer", prompt = "out font:", interactive = true, echo = true)
    private String answer;


    @Override
    public Integer call() throws Exception {
        MainTemplateConfig mainTemplateConfig = new MainTemplateConfig();
        BeanUtil.copyProperties(this, mainTemplateConfig);
        GeneratorMainTemplate.doGenerator(mainTemplateConfig);
        return null;
    }
}
